package com.weishenai.customerassistant.common;

import lombok.Data;

/**
 * @Auther: weishenai
 * @Date: 2021/11/27/12:05
 * @Description: 统一结果封装
 */
@Data
public class Result {
    private int code; //200表示正常
    private String message;
    private Object data;

    public static Result success(Object data) {
        return success(200, "操作成功", data);
    }

    public static  Result success(){
        return success(200,"","");
    }
    public static Result success(int code, String message, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result failed(String message) {
        return failed(400, message, null);
    }

    public static Result failed(String message, Object data) {
        return failed(400, message, data);
    }

    public static Result failed(int code, String message, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

}
